package com.example.mybatisjpa.repository;

import com.example.mybatisjpa.util.SpringUtils;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;

import java.util.List;

/**
 * @author Misty on 2020-12-03
 */
@NoRepositoryBean
public interface BaseRepository<T, ID> extends JpaRepository<T, ID> {
    SqlSessionTemplate instance = SpringUtils.getBean(SqlSessionTemplate.class);

    default List<T> getList(String statement) {
        return instance.selectList(statement);
    }

    default int insertList(String statement, List<T> list) {
        return instance.insert(statement, list);
    }
}
